#include "../h/User.h"
#include<string>
#include "Bank.h"
#include "ObjectsContainer.h"
#include <iostream>
using namespace std;

User::User()
{
	this->name = "a";
	this->ID = "0";
	this->acount = 0;
	this->energys = 0;
}
User::User(string name_, string ID_, Bank* acount_, double money_)
{
	this->name = name_;
	this->ID = ID_;
	this->acount = acount_;
	this->energys = new ObjectsContainer();
	this->deposit(money_);
	this -> theEnergysIconsumed = new ObjectsContainer();
	this -> theEnergysIcreated = new ObjectsContainer();
	this -> yesterdayBankStatus =money_;
	this -> profit =0;
}

User::~User()
{
	delete (this ->energys);
	delete (this ->theEnergysIconsumed);
	delete (this ->theEnergysIcreated);
}

void User::deposit(double amount)
{
	acount->deposit(name,amount);
}

void User::withdraw(double amount)
{
	acount->withdraw(name,amount);
}

double User::getUserStatus()
{
	return(acount->getUserStatus(name));
}

void User::consume(string energy,int amount)
{
	energys->remove(energy,amount);
	theEnergysIconsumed -> add(energy,amount);
}

void User::creat(string energy,int amount)
{
	energys->add(energy,amount);
	theEnergysIcreated -> add(energy,amount);
}

string User::getName()
{
	return this->name;
}

string User::getID()
{
	return this->ID;
}
void User::addEnergy(string energyType,int amount)
{
	energys->add(energyType,amount);
}

void User::removeEnergy(string energyType,int amount)
{
	energys->remove(energyType,amount);
}

double User::getEnergyStatus(string energyType)
{//int double
	return (energys -> getNameAmount(energyType));
}

int User::getConsumingSatus(string energyType)
{
	return this -> theEnergysIconsumed -> getNameAmount(energyType);
}

int User::getCreateStatus(string energyType)
{
	return this -> theEnergysIcreated -> getNameAmount(energyType);
}

void User::updateProfit()
{
	double acountMoney = acount ->getUserStatus(name);
	profit= acountMoney - yesterdayBankStatus;
	yesterdayBankStatus = acountMoney;
}

double User::getProfit()
{
	return profit;
}

